#pragma once

#include "Define.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_color_sinks.h"

namespace Origin
{
    class ORIGIN_API Log
    {
    public:
        static void Init();
        inline static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return _coreLogger; }
        inline static std::shared_ptr<spdlog::logger>& GetClientLogger() { return _clientLogger; }
    private:
        static std::shared_ptr<spdlog::logger> _coreLogger;
        static std::shared_ptr<spdlog::logger> _clientLogger;
    };

    #define ORIGIN_CORE_TRACE(...)  Origin::Log::GetCoreLogger()->trace(__VA_ARGS__)
    #define ORIGIN_CORE_INFO(...)   Origin::Log::GetCoreLogger()->info(__VA_ARGS__)
    #define ORIGIN_CORE_WARN(...)   Origin::Log::GetCoreLogger()->warn(__VA_ARGS__)
    #define ORIGIN_CORE_ERROR(...)  Origin::Log::GetCoreLogger()->error(__VA_ARGS__)
    #define ORIGIN_CORE_CRITICAL(...)  Origin::Log::GetCoreLogger()->critical(__VA_ARGS__)

    #define ORIGIN_CLIENT_TRACE(...)  Origin::Log::GetClientLogger()->trace(__VA_ARGS__)
    #define ORIGIN_CLIENT_INFO(...)   Origin::Log::GetClientLogger()->info(__VA_ARGS__)
    #define ORIGIN_CLIENT_WARN(...)   Origin::Log::GetClientLogger()->warn(__VA_ARGS__)
    #define ORIGIN_CLIENT_ERROR(...)  Origin::Log::GetClientLogger()->error(__VA_ARGS__)
    #define ORIGIN_CLIENT_CRITICAL(...)  Origin::Log::GetClientLogger()->critical(__VA_ARGS__)

    #ifdef ORIGIN_ENABLE_ASSERTS
    #define ORIGIN_CLIENT_ASSERT(x, msg) {if (!(x)) { ORIGIN_CLIENT_ERROR("Error: {0}", msg); __debugbreak(); } }
    #define ORIGIN_CORE_ASSERT(x, msg) { if (!(x)) { ORIGIN_CORE_ERROR("Error: {0}", msg); } }
    #else
    #define ORIGIN_CLIENT_ASSERT(x, msg)
    #define ORIGIN_CORE_ASSERT(x, msg)
    #endif
}

